<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>주소검색</title>
<style type="text/css">
a{
	text-decoration: none;
}
a:hover{
	text-decoration: underline;
}
li{
	padding-bottom: 5px;
	list-style-type: none; 
}


</style>

<script type="text/javascript">

function searchAddr(f){
	//입력여부확인하기
	if(f.dong.value==""){
		//공백처리하기
		alert("검색조건을 입력하세요!");
		return;
	}
	f.action='../member/search_addr.do';
	f.submit();
} 

function insertZip(){
	
	var zzipcode = document.getElementById("zzipcode").value;
	var zsido = document.getElementById("zsido").value;
	var zgugun = document.getElementById("zgugun").value;
	var zdong = document.getElementById("zdong").value;
	var zbunji = document.getElementById("zbunji").value;
	
	alert(zsido+" "+zgugun+" "+zdong+" "+zbunji);
	opener.join.m_addr1.value=zsido+" "+zgugun+" "+zdong+" "+zbunji;
	opener.join.m_zipcode.value=zzipcode;
	self.close();
}


</script>


</head>
<body>
	<div>
		<form name="searchaddr" id="f" method="post">

			
			
			<form>

			<table width=500 align=center border="1" style="font-size: medium;">

				<tr>
					<td colspan=2 align=center>입력창에 찾고자 하는 "동"을 입력해 주시기 바랍니다.</td>
				</tr>

				<tr>
					<td colspan=2 align=center><font size=2>예)삼성동,대치동,청담1동</font></td>
				</tr>

				<tr>
					<td width="100" align="center">지역명</td>

					<td width="100px">
					<input name="dong" type="text" style="width: 300px;">
					<input type="button" class="pink_button" value="검색"   onclick="searchAddr(this.form)" style="width: 50px;"></td>
				</tr>
			</table>
			</form>



			<!-- list 있음! -->
			<!-- list 있음! -->
			<div>
			<ul style="font-size: medium;">
				<c:if test='${!empty zlist}'>
					<c:forEach var="z" items="${zlist}">
					<input type="hidden" id="zzipcode" name="idx" value="${z.zipcode}">
							<input type="hidden" id="zsido" value="${z.sido}">
							<input type="hidden" id="zgugun" value="${z.gugun}">
							<input type="hidden" id="zdong" value="${z.dong}">
							<input type="hidden" id="zbunji" value="${z.bunji}">
							<li>
								<a href="#" onclick="insertZip()">
									${z.zipcode}&nbsp;&nbsp;
								</a>
								<a href="#" onclick="insertZip()">
									${z.sido}&nbsp;&nbsp;${z.gugun}&nbsp;&nbsp;${z.dong}&nbsp;&nbsp;${z.bunji}
								</a>
							</li>
		
					</c:forEach>
				</c:if>	
				
				<!--list 없음!-->
				<c:if test="${ empty zlist }">
					<li>
						선택된리스트가 없습니다.
					</li>
				</c:if>
			</ul>
			</div>
		</form>
	</div>
</body>
</html>